Example: A Dimer Sample

In [3]:
%pylab inline
#import ShapelyChipDesigns as SD
#reload(SD)
Populating the interactive namespace from numpy and matplotlib

In [4]:
################ use local developement version ##############

import imp, os, os.path, sys

sys.path.insert(0, "E:\\IPython2\\141007 Sphinx and ShapelyChipDesigns\\try4\\src")

def reload_rm(module_name):
    os.system('rm ' + str(module_name) + '.pyc')
    reload(module_name)

def import_(filename):
    path, name = os.path.split(filename)
    name, ext = os.path.splitext(name)

    print 'Before: %s in sys.modules ==' % name, name in sys.modules
    file, filename, data = imp.find_module(name, [path])
    print path
    mod = imp.load_module(name, file, filename, data)
    print 'After: %s in sys.modules ==' % name, name in sys.modules
    return mod

rePath = imp.find_module('ShapelyChipDesigns')[1]
SD = import_(rePath)
SD.__file__
Before: ShapelyChipDesigns in sys.modules == True
E:\IPython2\141007 Sphinx and ShapelyChipDesigns\try4\src
After: ShapelyChipDesigns in sys.modules == True

Out[4]:
'E:\\IPython2\\141007 Sphinx and ShapelyChipDesigns\\try4\\src\\ShapelyChipDesigns\\__init__.pyc'

Global Parameters

In [5]:
maskname = 'M34 '

chipheight = 2000
chipwidth  = 7000

RWC, RWG  = 10, 4.5 # Lars' thesis
epsilon   = 5.8     # Lars' thesis

c0        = 299792458
um        = 1e-6
GHz       = 1e9

Capacitors

In [6]:
### Left and right coupling capacitor:

wc      = RWC
wGgap   = RWG
ltaper  = 100
wgap    = 3
wGfinger = 7
n1      = 2
n2      = 2
wfinger = 3
lfinger = 42

CKL = SD.MakeFingercapacitor(n1, n2, wfinger, lfinger, wgap,ltaper, wc, wGgap, wGfinger)
CKR = CKL.make_copy()

figure(figsize=(4,4))
CKR.show_info()
SD.mouseshow()
{'R': [245, 0], 'L': [0, 0]}

Out[6]:
In [7]:
### Center capacitor
wc      = RWC
wGgap   = RWG
ltaper  = 100
wgap    = 3
wGfinger = 7
n1      = 2
n2      = 2
wfinger = 3
lfinger = 42

CJ = SD.MakeFingercapacitor(n2, n1, wfinger, lfinger, wgap,ltaper, wc, wGgap, wGfinger)
x, y = SD.anker(CJ.get_polygons('BOUNDARY')[0], 'center')
CJ.add_anker([x,y], 'center')
CJ.show_info()
{'R': [245, 0], 'L': [0, 0], 'center': [122.5, 0.0]}

Transmon

In [8]:
##### Parameters ########

l   = 100 # wiggle height 
r   = 16 # wiggle radius
n   = 11 # number of wiggles
p   = 10 # resolution
WIR = 19 # island-reservoir space between the fingers
W   = 10 # gap width
IRH = 130 # island + reservoir height
IRW = 325 # island + reservoir width
BH  = IRH+2*W # black box height
BW  = IRW+2*W # black box width

JJboxw = 26

########### Make the Transmon qubit ########

CX, CY = SD.wiggled_line(l,r,n,p)
T = SD.LineString(zip(CX, CY)) 
T = T.buffer(WIR/2.)

B = SD.mybox([0,0], IRW, IRH)
BB = SD.mybox([0,0],BW,BH)
BB = SD.translate(BB,xoff=0.5*(IRW-BW), yoff=0.5*(IRH-BH))

cx, cy = SD.anker(T, 'center')
bx, by = SD.anker(B, 'center')
T = SD.translate(T, bx-cx, by-cy)
x,y = SD.anker(T,'center')
T = SD.scale(T, yfact = -1)

# shrink one finger: 
xv = linspace(-JJboxw/2., JJboxw/2.)
jjb = SD.LineString(zip(xv,[0]*len(xv)))
JJB = jjb.buffer(JJboxw/2., cap_style=2)

JJB = SD.translate(JJB, xoff=x, yoff=y+0.85*l/2.)


####### Shrinked line: ##### 

TLnew = SD.unary_union([JJB,T])
TLnew = TLnew.buffer(6).buffer(-6)
TLnew = list(SD.flattenMultipoly(TLnew))[0]

######### Plot: #########

title('TMON: Parts + Shorten one finger')

SD.showPolygons([BB, B])
SD.showPolygons([TLnew], ['green'])
SD.showPolygons([T])

SD.showPolygons([JJB], ['yellow'])

plot(x,y,'o')
grid()

show()
In [9]:
########### Make the Transmon qubit ########

ISLAND,RESERVOIR= B.difference(TLnew)

TMON = SD.BRAND_NEW_STRUCTURE(BB,[])
TMON.EBL.add_polis([RESERVOIR,ISLAND])

########### Ankers ############
P = TMON.BOUNDARY.POLIS
x,y = P[0].boundary.xy
inds = SD.find_vertex('top', x,y)
ytop = [y[i] for i in inds[0]]
ytop = mean(ytop)
xtop = [x[i] for i in inds[0]]
xtop = mean(xtop)

TMON.add_anker([xtop, ytop], 
               'Flux Line')

#TMON.add_anker([BW/2., ytop],
#               'Flux Line')

P = TMON.BOUNDARY.POLIS
x, y = P[0].centroid.xy
TMON.add_anker([x[0],y[0]], 
               'EBL markers')

xl, yl = SD.anker(TMON.BOUNDARY.POLIS[0],'lower_left')
TMON.add_anker([xl,yl], 
               'Resonator LL')

xl, yl = SD.anker(TMON.BOUNDARY.POLIS[0],'lower_right')
TMON.add_anker([xl,yl],
               'Resonator LR')

TMON.show_info()
{'EBL markers': [162.5, 65.0], 'Resonator LL': [-10.0, -10.0], 'Flux Line': [162.5, 140.0], 'Resonator LR': [335.0, -10.0]}

EBL alignment markers

In [10]:
##########################
# larger EBL markers:
mwidth1  = 10
mlength1 = 30

markerlength, markerwidth = mlength1, mwidth1

P0 = SD.LineString([(-0.5,0),(0.5,0)])
M0 = SD.scale(P0, markerlength)
M1 = SD.rotate(M0,90)

M00 = M0.buffer(markerwidth/2., cap_style=3)
M11 = M1.buffer(markerwidth/2., cap_style=3)

MEBL1 = M00.union(M11)

##########################
# smaller EBL markers:
mwidth2  = 2
mlength2 = 12

markerlength, markerwidth = mlength2, mwidth2

P0 = SD.LineString([(-0.5,0),(0.5,0)])
M0 = SD.scale(P0, markerlength)
M1 = SD.rotate(M0,90)

M00 = M0.buffer(markerwidth/2., cap_style=3)
M11 = M1.buffer(markerwidth/2., cap_style=3)

MEBL2 = M00.union(M11)

# marker positions
wfsize = 500 

ps1 = SD.get_RegPoly_xy((0,0), 
                        wfsize-2*mlength1, 
                        3)
ps2 = SD.get_RegPoly_xy((0,0), 
                        wfsize-2*mlength1-5*mlength2, 
                        3)

# add outer markers
MARKERS = []

marker = MEBL1
POINTS = zip(ps1[0],ps1[1])

for p in POINTS:
    M = SD.translate(marker, p[0],p[1])
    MARKERS += [M]
    
# add inner markers

marker = MEBL2
POINTS = zip(ps2[0], ps2[1])

for p in POINTS:
    M = SD.translate(marker, 
                     p[0], p[1])
    MARKERS += [M]
    
EBLMARKERS = SD.BRAND_NEW_STRUCTURE(MARKERS,
                                    [SD.empty()])

EBLMARKERS.add_anker([0,0], 'center')
EBLMARKERS.rotate(-90, EBLMARKERS.ANKERS['center'])

SD.showPolygons(EBLMARKERS.get_polygons())

S = EBLMARKERS
for k in S.ANKERS.keys():
    x,y = S.ANKERS[k]
    plot(x,y,'o', markersize=5, label=str(k))

    
grid()
show()

Fluxline

In [11]:
d = 50 
w = 5.0
h = 10

o = 25

ti  = array([[0,o], 
             [0,o+h]])
tii = array([[-d,0.0], 
             [d,0.0]])

TI  = SD.MakeTransmissionLine(ti[:,0],  ti[:,1],  RWC, RWG)
TII = SD.MakeTransmissionLine(tii[:,0], tii[:,1], w, w)

abox = SD.mybox((-(RWC/2.+RWG),0), 2*RWG+RWC, o)

#FLUX = SD.BRAND_NEW_STRUCTURE(TI.BOUNDARY.union(TII.BOUNDARY),TI.STRUCTURE.union(TII.STRUCTURE))

FLUX = SD.BRAND_NEW_STRUCTURE(SD.unary_union([TI.BOUNDARY.POLIS[0],abox]),TI.STRUCTURE.POLIS)

FLUX.add_anker([0,o+h],'to Launcher')
FLUX.add_anker([0,0],'to TMON')

SD.showPolygons(FLUX.get_polygons())

for k in FLUX.ANKERS.keys():
    x,y = FLUX.ANKERS[k]
    plot(x,y,'o', markersize=5, label=str(k))

legend()
grid()
tight_layout()
SD.mouseshow()
Out[11]:
In [12]:
FLUX.ANKERS
Out[12]:
{'to Launcher': [0, 35], 'to TMON': [0, 0]}
In [13]:
FLUX.translate(TMON.ANKERS['Flux Line'],
           FLUX.ANKERS['to TMON'])

EBLMARKERS.translate(TMON.ANKERS['EBL markers'],
                 EBLMARKERS.ANKERS['center'])
 
TMONPLUS = SD.BRAND_NEW_STRUCTURE(TMON.BOUNDARY.POLIS+EBLMARKERS.BOUNDARY.POLIS+FLUX.BOUNDARY.POLIS, 
                                  TMON.STRUCTURE.POLIS+EBLMARKERS.STRUCTURE.POLIS+FLUX.STRUCTURE.POLIS)

S = TMON
for k in S.ANKERS.keys():
    x,y = S.ANKERS[k]
    TMONPLUS.add_anker([x,y], k)
    
TMONPLUS.add_anker(FLUX.ANKERS['to Launcher'], 'to Launcher')
    
TMONPLUS.add_layer(TMON.get_polygons('EBL'), 'EBL')

TMONPLUS.show_info()
SD.mouseshow()
{'EBL markers': [162.5, 65.0], 'to Launcher': [162.5, 175.0], 'Resonator LL': [-10.0, -10.0], 'Flux Line': [162.5, 140.0], 'Resonator LR': [335.0, -10.0]}

Out[13]:

Text

In [14]:
textheight = chipheight/10
X_text     = chipwidth/2
Y_text     = chipheight/10

mystr = SD.NotebookName()
dig = [int(s) for s in mystr if s.isdigit()]
let = [s for s in mystr.split(str(dig[0]))]

TEXTlist = []

for i in arange(dig[0], dig[1]+2):
    
    textpoly   = SD.text2poly(maskname+let[0]+str(i-1), textheight)
    
    llx, lly = SD.anker(textpoly[0],'lower_left')
    urx, ury = SD.anker(textpoly[-1],'upper_right')
    
    width  = urx - llx 
    height = (ury - lly)*1.5
    
    textbound = SD.mybox((-0.1*width,-0.1*height),1.2*width,1.2*height)
    
    TEXT = SD.BRAND_NEW_STRUCTURE(textbound, textpoly)
    xc, yc = SD.anker(TEXT.BOUNDARY.POLIS[0],'center')
    TEXT.translate([X_text,Y_text], [xc,yc])
    
    TEXTlist += [TEXT]
    
SD.showPolygons(TEXTlist[3].get_polygons())

Alignment markers

In [15]:
markerwidth = 4
markerlength = 20 

P0 = SD.LineString([(-0.5,0),(0.5,0)])
M0 = SD.scale(P0, markerlength)
M1 = SD.rotate(M0,90)

M00 = M0.buffer(markerwidth/2., cap_style=3)
M11 = M1.buffer(markerwidth/2., cap_style=3)

marker = M00.union(M11)

SD.showPolygons([marker])
In [16]:
distance = 50 
n = 5

POINTS = []

MARKERS = []
BOXES = []
abox = SD.mybox((-markerlength/2., -markerlength/2.),
                markerlength, 
                markerlength)

for x in arange(n):
    for y in arange(n):
        POINTS += [[x*distance,y*distance]]
        
for p in POINTS:
    M = SD.translate(marker, p[0],p[1])
    B = SD.translate(abox, p[0],p[1])
    scatter(p[0],p[1],s=100)
    MARKERS += [M]
    BOXES += [B]
    
CHIPMARKERS = SD.BRAND_NEW_STRUCTURE(MARKERS,[SD.empty()])

########### PHOTOLITHO MARKER #############
factor = n*distance/markerlength
photomarker = SD.scale(marker, factor, factor)
P = SD.unary_union(CHIPMARKERS.BOUNDARY.POLIS)
xc,yc = P.centroid.xy
#xc,yc = CHIPMARKERS.get_ankerpoint('center')
photomarker = SD.translate(photomarker, xc[0], yc[0])

largebox = SD.mybox((-2*markerlength, -2*markerlength),(n+0.5)*distance, (n+0.5)*distance)
photomarkerStruc2 = largebox

for B in BOXES:
    photomarker = photomarker.difference(B)
    photomarkerStruc2 = photomarkerStruc2.difference(B)

photomarkerStruc2 = photomarkerStruc2.difference(photomarker)
photomarkerStruc2 = SD.flattenMultipoly(photomarkerStruc2)
photomarkerStruc2 = list(photomarkerStruc2)
#SD.showPolygons([photomarker])

CHIPMARKERS.add_layer(photomarker, 'STRUC1')
CHIPMARKERS.add_layer(photomarkerStruc2, 'STRUC2')

CHIPMARKERS.show_info()
SD.mouseshow()
{}

Out[16]:
In [17]:
px, py = 0.05, 0.2

c0 = (px*chipwidth, py*chipheight)
c1 = (px*chipwidth, (1-py)*chipheight)
c3 = ((1-px)*chipwidth, (1-py)*chipheight)
c4 = ((1-px)*chipwidth, py*chipheight)

cs = [c0, c1, c3, c4]
aligns = ['lower_left', 'upper_left', 'upper_right', 'lower_right']

for i, c in enumerate(cs):
    ax, ay = CHIPMARKERS.BOUNDARY.get_ankerpoint(aligns[i])
    CHIPMARKERS.translate(c,[ax,ay])
    SD.showPolygons(CHIPMARKERS.get_polygons())

grid()
SD.mouseshow()
Out[17]:

Resonators

Airbridge

In [18]:
A1a, A1b = SD.get_airbridge_poly1()
A2 = SD.get_airbridge_poly2()
SD.showPolygons([A2,A1a, A1b])

Add the airbridge to the resonator

In [19]:
length = 8600
width  = 2300
wradius = 100
wnumber = 5

reload(SD)

x,y =  SD.make_resonator(length,
                         width,
                         wradius,
                         wnumber)

dummy = SD.LineString(zip(x,y))
print dummy.length
print 'Expected resonance frequency: ', c0/(2*(dummy.length+2*ltaper+2*0.6*lfinger)*um*sqrt(epsilon))/GHz

###############################

RESI = SD.MakeTransmissionLine(x,y,RWC,RWG)

####### AIRBRIDGES #####

S1a, S2 =  SD.get_airbridge_polys(x,y,
                                 A1a,A2,
                                 10) 

S1b, S2 =  SD.get_airbridge_polys(x,y,
                                 A1b,A2,
                                 10) 

RESI.add_layer(S1a+S1b, 'STRUC1')
RESI.add_layer(S2,      'STRUC2')

######## ANKERS 

RESI.add_anker(RESI.ANKERS[0],'left')
RESI.add_anker(RESI.ANKERS[1],'right')
RESI.add_anker(RESI.ANKERS[0]+array([length/50.,0.5*(RWC+RWG)]), 'TMON')

RESII = RESI.make_copy()
print RESII.ANKERS
xc, yc = RESII.BOUNDARY.get_ankerpoint('center')

OldRight = RESII.ANKERS['right']
OldLeft = RESII.ANKERS['left']
RESII.add_anker(OldRight,'left')
RESII.add_anker(OldLeft,'right')

RESII.scale(-1,1,[xc,yc])
############### PLOT #############
figure(figsize=(8,6))
subplot(121)
S = RESI

SD.showPolygons(S.get_polygons())
SD.showPolygons(S.get_polygons('STRUC1'))
SD.showPolygons(S.get_polygons('STRUC2'))

for k in S.ANKERS.keys():
    x,y = S.ANKERS[k]
    plot(x,y,'o', markersize=10, label=str(k))

legend()

subplot(122)
S = RESII
SD.showPolygons(S.get_polygons())

for k in S.ANKERS.keys():
    x,y = S.ANKERS[k]
    plot(x,y,'o', markersize=10, label=str(k))
    
SD.showPolygons(S.get_polygons('STRUC1'))
SD.showPolygons(S.get_polygons('STRUC2'))

legend()

tight_layout()
SD.mouseshow()
8597.71557954
Expected resonance frequency:  [  8.21245995e-06   9.38566852e-06]
{0: [-650.0, 681.50444078461248], 1: [1650.0, 681.50444078461248], 'right': [1650.0, 681.50444078461248], 'TMON': array([-478.        ,  688.75444078]), 'left': [-650.0, 681.50444078461248]}

Out[19]:

Launchers

In [20]:
RWClarge = 150.  # launcher conductor width
RWGlarge = 70.   # gap: launcher - groundplane
length   = 250.  # length of the launcher
length2  = 150.  # length of the starter
shuntwidth = 30. # width of the little square on the left side of the starter

##### STRAIGHT STARTER #####

STARTER = SD.MakeTransmissionLine([-length2,0], [0,0],
                                    RWClarge, RWGlarge)

i, o = SD.get_launcher_xy(RWC, RWG, RWClarge, RWGlarge, length)
#plot(i[:,0], i[:,1],'o-')
#plot(o[:,0], o[:,1],'o-')

LAI = SD.Polygon(i)
LAO = SD.Polygon(o)

##### SHUNT ################

GPLANESHUNT = SD.mybox((-length2, -RWClarge/2.), shuntwidth, RWClarge)

##### MAKE THE LAUNCHER ####

LAUNCHER_HR = SD.BRAND_NEW_STRUCTURE([LAO]+STARTER.BOUNDARY.POLIS, \
                                     [LAI]+[STARTER.STRUCTURE.POLIS[0].difference(GPLANESHUNT)])

LAUNCHER_HR.show_info()
{}

In [21]:
##### ANKERS ###############

ax, ay = -length2, 0

LAUNCHER_HR.add_anker([ax,ay],'G')
LAUNCHER_HR.add_anker([length,0], 'to Tline')

LAUNCHER_VU = LAUNCHER_HR.make_copy()
LAUNCHER_VU.rotate(90, [ax,ay])

LAUNCHER_HL = LAUNCHER_HR.make_copy()
LAUNCHER_HL.rotate(180, [ax,ay])

LAUNCHER_VD = LAUNCHER_HR.make_copy()
LAUNCHER_VD.rotate(270, [ax,ay])

######## Plot ##############

subplot(121)

LAUNCHER_HR.show_info()
axis('equal')

### 

subplot(122)
LAUNCHER_VD.show_info()
legend()
axis('equal')
SD.mouseshow()
{'to Tline': [250.0, 0], 'G': [-150.0, 0]}
{'to Tline': [-150.0, -400.0], 'G': [-150.0, 0.0]}

Out[21]:

Connect

In [22]:
reload(SD)
G = SD.GROUNDPLANE(chipwidth,chipheight)
        
######### Ankers ###########
G.add_anker([0,chipheight/2.], 'L: HR')
G.add_anker([chipwidth, chipheight/2.], 'L: HL')
G.add_anker([1000, chipheight], 'L: VD (I)')
G.add_anker([6000, chipheight], 'L: VD (II)')
G.add_anker([0.5*chipwidth, 0.5*chipheight], 'C center')

for i, c in enumerate(cs):
    G.add_anker(c, 'Chipmarker '+str(i))

######## Plot ##############
        
for k in G.ANKERS.keys():
    x,y = G.ANKERS[k]
    plot(x,y,'o', markersize=10, label=str(k))

SD.showPolygons(G.get_polygons())
legend()
tight_layout()
SD.mouseshow()
Out[22]:
In [23]:
#import allparts as AP
#reload(AP)
In [24]:
TMONPLUS_II = TMONPLUS.make_copy()
LAUNCHER_VDII = LAUNCHER_VD.make_copy()
In [25]:
parts = SD.all_parts(globals())
In [26]:
names = ['TMONPLUS',
         'TMONPLUS_II',
        'RESI',
        'RESII',
        'CKL',
        'CKR',
        'CJ', 
        'FLUX', 
        'LAUNCHER_HR',
        'LAUNCHER_HL',
        'LAUNCHER_VD',
        'LAUNCHER_VDII',
        'G']
In [27]:
for name in names: 
    parts.add_part(name)
In [28]:
parts.get_part_table()
Out[28]:
TMONPLUS['EBL markers', 'to Launcher', 'Resonator LL', 'Flux Line', 'Resonator LR']
TMONPLUS_II['EBL markers', 'to Launcher', 'Resonator LL', 'Flux Line', 'Resonator LR']
RESI[0, 1, 'right', 'TMON', 'left']
RESII[0, 1, 'right', 'TMON', 'left']
CKL['R', 'L']
CKR['R', 'L']
CJ['R', 'L', 'center']
FLUX['to Launcher', 'to TMON']
LAUNCHER_HR['to Tline', 'G']
LAUNCHER_HL['to Tline', 'G']
LAUNCHER_VD['to Tline', 'G']
LAUNCHER_VDII['to Tline', 'G']
G[0, 'C center', 'L: HR', 'L: VD (I)', 'L: VD (II)', 'L: HL', 'Chipmarker 0', 'Chipmarker 1', 'Chipmarker 2', 'Chipmarker 3']
In [29]:
parts.join_parts('G', 'CJ', 
                 ['C center','center'])

parts.join_parts('CJ', 'RESI', 
                 ['L','right'])

parts.join_parts('CJ', 'RESII', 
                 ['R','left'])

parts.join_parts('RESI', 'TMONPLUS', 
                 ['TMON','Resonator LL'])

parts.join_parts('RESII', 'TMONPLUS_II', 
                 ['TMON','Resonator LR'])

parts.join_parts('RESI', 'CKL', 
                 ['left','R'])

parts.join_parts('RESII', 'CKR', 
                 ['right','L'])

parts.join_parts('G', 'LAUNCHER_VDII', 
                 ['L: VD (II)','G'])

parts.join_parts('G', 'LAUNCHER_VD', 
                 ['L: VD (I)','G'])

parts.join_parts('G', 'LAUNCHER_HR', 
                 ['L: HR','G'])

parts.join_parts('G', 'LAUNCHER_HL', 
                 ['L: HL','G'])
I am so much new!
I am so much new!
I am so much new!
I am so much new!
I am so much new!
I am so much new!
I am so much new!
I am so much new!
I am so much new!
I am so much new!
I am so much new!
I am so much new!

In [30]:
Connections = []

################ CAPACITOR - LAUNCHER CONNECTION #########

aline = SD.connect_v(LAUNCHER_HR.ANKERS['to Tline'], 
                     CKL.ANKERS['L'])

C = SD.MakeTransmissionLine(aline[:,0],aline[:,1],RWC,RWG)
Connections += [C]

aline = SD.connect_v(LAUNCHER_HL.ANKERS['to Tline'], 
                     CKR.ANKERS['R'])
C = SD.MakeTransmissionLine(aline[:,0],aline[:,1],RWC,RWG)
Connections += [C]
In [31]:
from ShapelyChipDesigns import smooth
In [32]:
################ CHARGE LINES ################
### C1

make_smooth = True 

aline = SD.connect_h(LAUNCHER_VD.ANKERS['to Tline'], 
                     TMONPLUS.ANKERS['to Launcher'], D=0.39)
if make_smooth: aline = smooth.smoothen(SD.LineString(aline), 100, 50)

x, y = aline[:,0], aline[:,1]

S1a, S2 =  SD.get_airbridge_polys(x,y,
                                 A1a,A2,
                                 4)   

S1b, S2 =  SD.get_airbridge_polys(x,y,
                                 A1b,A2,
                                 4) 

B1 = SD.BRAND_NEW_STRUCTURE([],[])
B1.add_layer(S1a+S1b, 'STRUC1')
B1.add_layer(S2, 'STRUC2')
G.add_shapes([B1])

#C = SD.MakeTransmissionLine(aline[:,0],aline[:,1],RWC,RWG)
aline = SD.LineString(aline)
SO = aline.buffer(RWC/2.+RWG,cap_style=2)
SI = aline.buffer(RWC/2.,cap_style=2)
C = SD.BRAND_NEW_STRUCTURE(SO,SI)
Connections += [C]

### C2

aline = SD.connect_h(LAUNCHER_VDII.ANKERS['to Tline'], 
                     TMONPLUS_II.ANKERS['to Launcher'],D=0.39)

s = aline

if make_smooth: aline = smooth.smoothen(SD.LineString(aline), 100, 50)
    
x, y = aline[:,0], aline[:,1]

A1a, A1b = SD.get_airbridge_poly1()
A2 = SD.get_airbridge_poly2()
'''
A10, A20 = SD.get_airbridge_poly(40, 10, 
                                 60, 20)
'''

S1a, S2 =  SD.get_airbridge_polys(x,y,
                                 A1a,A2,
                                 4)   

S1b, S2 =  SD.get_airbridge_polys(x,y,
                                 A1b,A2,
                                 4) 

B1 = SD.BRAND_NEW_STRUCTURE([],[])
B1.add_layer(S1a+S1b, 'STRUC1')
B1.add_layer(S2, 'STRUC2')
G.add_shapes([B1])
    
#C = SD.MakeTransmissionLine(aline[:,0],aline[:,1],RWC,RWG)
aline = SD.LineString(aline)
SO = aline.buffer(RWC/2.+RWG,cap_style=2)
SI = aline.buffer(RWC/2.,cap_style=2)
C = SD.BRAND_NEW_STRUCTURE(SO,SI)
Connections += [C]
In [33]:
for p in parts.D.values()[::-1]:
    SD.showPolygons(p.get_polygons())
    
for C in Connections:
    SD.showPolygons(C.get_polygons())
    
SD.mouseshow()
Out[33]:
In [34]:
G.add_shapes(parts.D.values())
G.add_shapes(Connections)
In [35]:
for i, c in enumerate(cs):
    ax, ay = CHIPMARKERS.BOUNDARY.get_ankerpoint(aligns[i])
    CHIPMARKERS.translate(c,[ax,ay])
    G.add_shapes([CHIPMARKERS])
In [36]:
SD.showPolygons(G.get_polygons()+G.get_polygons('STRUC2')+G.get_polygons('STRUC1')+G.get_polygons('EBL'))
   
axis('scaled')
grid()
SD.mouseshow()
Out[36]:
In [37]:
G2 = G.make_copy()
i = 3
G2.add_shapes([TEXTlist[i]])

figure()
SD.showPolygons(G2.get_polygons()+G2.get_polygons('STRUC2')+\
                G2.get_polygons('STRUC1')+G2.get_polygons('EBL'))
#SD.showPolygons(TEXTlist[i].get_polygons())
SD.mouseshow()
Out[37]:
In [38]:
SD.showPolygons(G2.get_polygons('STRUCTURE'))
In [39]:
G2.layers
Out[39]:
{'BOUNDARY': <ShapelyChipDesigns.brandnew_structure.LAYER instance at 0x08B5A2B0>,
 'EBL': <ShapelyChipDesigns.brandnew_structure.LAYER instance at 0x08B5A4B8>,
 'STRUC1': <ShapelyChipDesigns.brandnew_structure.LAYER instance at 0x08B5A1E8>,
 'STRUC2': <ShapelyChipDesigns.brandnew_structure.LAYER instance at 0x08B5A238>,
 'STRUCTURE': <ShapelyChipDesigns.brandnew_structure.LAYER instance at 0x08B5A850>}
In [40]:
G2.layers.keys()
Out[40]:
['STRUC1', 'EBL', 'BOUNDARY', 'STRUC2', 'STRUCTURE']
In [41]:
reload_rm(SD)
In [53]:
fig = figure(figsize=(10,4))
G2.show_info()
axis('scaled')
SD.mouseshow()
so new

Out[53]:
In [54]:
import mpld3
mpld3.save_html(fig, "E:/IPython2/141007 Sphinx and ShapelyChipDesigns/try4/docs/pyplots/img/E1_E3.html")
In [49]:
fig = figure(figsize=(10,4))
GRnew = SD.invert_polarity(G2.G0[0], G2.get_polygons())
SD.showPolygons(GRnew)
axis('scaled')
SD.mouseshow()
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412

Out[49]:

DXF Export

In [44]:
mystr = SD.NotebookName()
dig = [int(s) for s in mystr if s.isdigit()]
let = [s for s in mystr.split(str(dig[0]))]

for i in arange(dig[0], dig[1]+1):
    G2 = G.make_copy()
    G2.add_shapes([TEXTlist[i]])
    SD.savedxf_polylist(G2.get_polygons(), './dxf/'+let[0]+str(i))
    SD.savedxf_polylist(G2.get_polygons('STRUC1'),   './dxf/'+'layer1_'+let[0]+str(i))
    SD.savedxf_polylist(G2.get_polygons('STRUC2'),   './dxf/'+'layer2_'+let[0]+str(i))
    SD.savedxf_polylist(G2.get_polygons('EBL'),      './dxf/'+'layerEBL_'+let[0]+str(i))
    SD.savedxf_polylist(G2.get_polygons()+G2.get_polygons('EBL')+G2.get_polygons('STRUC2')+G2.get_polygons('STRUC1'), \
                                           './dxf/'+'alllayers_'+let[0]+str(i))
    GRnew = SD.invert_polarity(G2.G0[0], G2.get_polygons())
    SD.savedxf_polylist(GRnew,             './dxf/'+'layer0_'+let[0]+str(i))
    
    SD.convert('./dxf/'+'layer1_'+let[0]+str(i)+'.dxf', 
               './dxf/'+'layer1_'+let[0]+str(i)+'.dxf')
    SD.convert('./dxf/'+'layer2_'+let[0]+str(i)+'.dxf',
               './dxf/'+'layer2_'+let[0]+str(i)+'.dxf')
    SD.convert('./dxf/'+'layerEBL_'+let[0]+str(i)+'.dxf',
                './dxf/'+'layerEBL_'+let[0]+str(i)+'.dxf')
    SD.convert('./dxf/'+'alllayers_'+let[0]+str(i)+'.dxf',
               './dxf/'+'alllayers_'+let[0]+str(i)+'.dxf')
    SD.convert('./dxf/'+'layer0_'+let[0]+str(i)+'.dxf',
               './dxf/'+'layer0_'+let[0]+str(i)+'.dxf')
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412

saved ./dxf/E1.dxf
saved ./dxf/layer1_E1.dxf
saved ./dxf/layer2_E1.dxf
saved ./dxf/layerEBL_E1.dxf
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412


saved ./dxf/alllayers_E1.dxf
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412


saved ./dxf/layer0_E1.dxf
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 6438 412
WARNING:shapely.geos:Too few points in geometry component at or near point 6438 412


saved ./dxf/E2.dxf
saved ./dxf/layer1_E2.dxf
saved ./dxf/layer2_E2.dxf
saved ./dxf/layerEBL_E2.dxf
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 6438 412
WARNING:shapely.geos:Too few points in geometry component at or near point 6438 412


saved ./dxf/alllayers_E2.dxf
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 6438 412


saved ./dxf/layer0_E2.dxf
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412


saved ./dxf/E3.dxf
saved ./dxf/layer1_E3.dxf
saved ./dxf/layer2_E3.dxf
saved ./dxf/layerEBL_E3.dxf
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412


saved ./dxf/alllayers_E3.dxf
WARNING:shapely.geos:Too few points in geometry component at or near point 362 412


saved ./dxf/layer0_E3.dxf

---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-44-4db078cf2355> in <module>()
     15 
     16     SD.convert('./dxf/'+'layer1_'+let[0]+str(i)+'.dxf', 
---> 17                './dxf/'+'layer1_'+let[0]+str(i)+'.dxf')
     18     SD.convert('./dxf/'+'layer2_'+let[0]+str(i)+'.dxf',
     19                './dxf/'+'layer2_'+let[0]+str(i)+'.dxf')

C:\Python27\lib\site-packages\ShapelyChipDesigns\in_out_show.pyc in convert(input_filename, output_filename)
    246     if the command is not found, klayout needs to be added to the PATH variable.)"""
    247     c_file = pkg_resources.resource_filename('ShapelyChipDesigns', 'convert.rb')
--> 248     os.system('klayout -rd input='+input_filename+' -rd output='+output_filename+' -r '+c_file)
    249 
    250 def mouseshow():

KeyboardInterrupt: 
In []:
G2 = G.make_copy()
G2.add_shapes([TEXTlist[3]])
GRnew = SD.invert_polarity(G2.G0[0], G2.get_polygons())
SD.showPolygons(GRnew)
SD.mouseshow()

Convert to html

In [50]:
!ipython nbconvert E1_E3.ipynb --to rst
[NbConvertApp] Using existing profile dir: u'C:\\Users\\Anna\\.ipython\\profile_default'
[NbConvertApp] Converting notebook E1_E3.ipynb to rst
[NbConvertApp] Support files will be in E1_E3_files\
[NbConvertApp] Loaded template rst.tpl
[NbConvertApp] Writing 4282420 bytes to E1_E3.rst

In [51]:
f = open('E1_E3.rst', 'r')
content = f.read()
f.close()
content = content.replace('%5C','/')

f = open('E1_E3.rst', 'w')
f.write(content)
f.close()
In [52]:
!ipython nbconvert --to html *.ipynb
[NbConvertApp] Using existing profile dir: u'C:\\Users\\Anna\\.ipython\\profile_default'
[NbConvertApp] Converting notebook E1_E3.ipynb to html
[NbConvertApp] Support files will be in E1_E3_files\
[NbConvertApp] Loaded template full.tpl
C:\Python27\lib\site-packages\IPython\nbconvert\filters\markdown.py:78: UserWarning: Node.js 0.9.12 or later wasn't found.
Nbconvert will try to use Pandoc instead.
  "Nbconvert will try to use Pandoc instead.")
[NbConvertApp] Writing 4714693 bytes to E1_E3.html
[NbConvertApp] Converting notebook hello.ipynb to html
[NbConvertApp] Support files will be in hello_files\
[NbConvertApp] Writing 205598 bytes to hello.html
[NbConvertApp] Converting notebook Installation.ipynb to html
[NbConvertApp] Support files will be in Installation_files\
[NbConvertApp] Writing 189237 bytes to Installation.html
[NbConvertApp] Converting notebook Introduction.ipynb to html
[NbConvertApp] Support files will be in Introduction_files\
[NbConvertApp] Writing 466734 bytes to Introduction.html

In []:
 
In []: